const { uniacid } = require("../../../siteinfo");

const App = getApp();

Page({

  /**
   * 页面的初始数据
   */
  data: {

  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    this.fetchAdver()
  },
  // 获取广告
  fetchAdver() {
    App._post_form('info/getAdverts', {
      type: 1
    }, (res) => {
      console.log(res.data)
      this.setData({
        adverts: res.data.adverts
      })
    });
  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
    // 获取推广二维码
    this.getPoster();
  },

  /**
   * 获取推广二维码
   */
  getPoster: function () {
    let _this = this;
    wx.showLoading({
      title: '加载中',
    });
    App._get('user.dealer.qrcode/poster', {}, function (result) {
      // 设置当前页面标题
      wx.setNavigationBarTitle({
        title: result.data.words.qrcode.title.value
      })
      _this.setData(result.data);
     
    }, null, function (res) {
      if(res.code==2000){
        wx.navigateTo({
          url: '../../dealer/apply/apply',
        })
      }
        
      wx.hideLoading();
    });
  },

  previewImage: function () {
    wx.previewImage({
      current: this.data.qrcode,
      urls: [this.data.qrcode]
    })
  },

})